<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="js/vue.min.js"></script>
    <script src="js/vue-router.js"></script>
    <style>
        .router-link-active, .myactive {
            color: red;
            font-weight: 800;
            font-style: italic;
            font-size: 80px;
            text-decoration: underline;
            background-color: greenyellow;
        }

        .v-enter,
        .v-leave-to {
            opacity: 0;
            transform: translateX(140px);
        }

        .v-enter-active,
        .v-leave-active {
            transition: all 0.5s ease;
        }
    </style>
</head>
<body>
<div id="app">
    <router-link to="login/10" tag="span">登录</router-link>
    <router-link to="register" tag="span">注册</router-link>
    <router-view></router-view>
</div>
<script>
    const login = {
        template: '<h1>登录组件</h1>',
        created() {
            console.log(this.$route)
            console.log(this.$route.params.id)
        }

    };

    const register = {
        template: '<h1>注册组件</h1>'
    };

    const router = new VueRouter({
        routes: [
            {path: '/login/:id', component: login},
            {path: '/register', component: register}
        ],
        linkActiveClass: 'myactive'
    });
    const vm = new Vue({
        el: '#app',
        data: {},
        methods: {},
        router: router

    })
</script>
</body>
</html>